package com.fj.product.web;

import com.fj.domain.Product;
import com.fj.domain.User;
import com.fj.product.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author fj
 * @date 2024/3/11 23:55
 */
@Slf4j
@RestController
@RequestMapping(value = "product")
public class ProductController {

    @Autowired
    private ProductService productService;

    @RequestMapping(value = "{pid}",method = RequestMethod.GET)
    public Product getProduct(@PathVariable(value = "pid") Integer pid){
        log.info("获取产品");
        return productService.getProduct(pid);
    }

    @RequestMapping(value = "reduceStock",method = RequestMethod.POST)
    public Product reduceStock(@RequestParam(value = "pid") Integer pid,@RequestParam(value = "number") Integer number){
        log.info("扣减库存");
        return productService.reduceStock(pid,number);
    }
}
